
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<%@ include file="/include/head.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/servicePro/jquery.uploadify.min.js"></script>
<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/servicePro/uploadify.css">
<script type="text/javascript"
	src="<%=request.getContextPath()%>/resources/problem/lytebox.js"></script>
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/resources/problem/lytebox.css">
	<script type="text/javascript"
	src="<%=request.getContextPath()%>/resources/layer/layer.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/resources/layer/extend/layer.ext.js"></script>
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/resources/layer/skin/layer.css">
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/resources/layer/skin/layer.ext.css">
<script type="text/javascript">
      $(function(){  
		   /**加载修改友情链接框**/
		  $("#update_manager_dialog").dialog({
		    autoOpen : false,
		    width : 700,
		    draggable : true,
		    resizable : false,
		    height:550,
		    buttons : [ {
		      text : "提交",
		      click : function() {
		      	  updateManager();
		     	 $(this).dialog("close");		      	
		      }
		    }, {
		      text : "取消",
		      click : function() {
		        $(this).dialog("close");
		        
		      }
		    } ]
	  });
	   /**加载添加友情链接框**/
		  $("#add_manager_dialog").dialog({
		    autoOpen : false,
		    width : 700,
		    draggable : true,
		    resizable : false,
		    height:300,
		    buttons : [ {
		      text : "提交",
		      click : function() {
		      	  addManager();
		     	 $(this).dialog("close");		      	
		      }
		    }, {
		      text : "取消",
		      click : function() {
		        $(this).dialog("close");
		        
		      }
		    } ]
	  });
		  $("#add_manager").click(function(e) {
	        closeOtherJDialog();
	        e.stopPropagation();
	        $("#add_manager_dialog").dialog('open');
	     });
	       $("#file_upload").uploadify({
        		    'buttonText' : '请选择图片',
        		    'height' : 30,
        	        'swf' : '<%=request.getContextPath()%>/resources/servicePro/uploadify.swf',
        	        'uploader' : '<%=request.getContextPath()%>/back/actBack/uploadlogo.do',
        	        'width' : 120,
        	        'multi'           : false,
                    "auto"            : false,
                    "dnd"             : true,
        	        "fileTypeExts"    : "*.png;*.jpg;*.bmp;*.gif",
                    "fileSizeLimit"   : "2MB",
        	        'fileObjName'   : 'file',
        	        'onUploadSuccess' : function(file, data, response) {
        	        	      data = eval("(" + data + ")");      	        
        	                 alert( file.name + ' 上传成功！ ');
                           $("#ipic").val(data.picurl);
        	            $("#uploadButton").hide();
        	            
        	        },
         'onFallback' : function() {
           alert('Flash was not detected.');
        },
         "onSelect" : function(file) {
          if ($("#file_upload-queue").children().length == 1) {
            $("#uploadButton").show();
            $("#onlyOneImg").hide();
          } else {
          
            $("#uploadButton").hide();
            $("#onlyOneImg").show();
          }
        },
           "onCancel" : function() {
          if ($("#file_upload-queue").children().length == 2) {
            $("#uploadButton").show();
            $("#onlyOneImg").hide();
          } else if ($("#file_upload-queue").children().length == 1) {
            $("#uploadButton").hide();
          } else {
            $("#uploadButton").hide();
            $("#onlyOneImg").show();
          }
        },
 		        });
 		        
 		        
 		             $("#ufile_upload").uploadify({
        		    'buttonText' : '请选择图片',
        		    'height' : 30,
        	        'swf' : '<%=request.getContextPath()%>/resources/servicePro/uploadify.swf',
        	        'uploader' : '<%=request.getContextPath()%>/back/actBack/uploadlogo.do',
        	        'width' : 120,
        	        'multi'           : false,
                    "auto"            : false,
                    "dnd"             : true,
        	        "fileTypeExts"    : "*.png;*.jpg;*.bmp;*.gif",
                    "fileSizeLimit"   : "2MB",
        	        'fileObjName'   : 'file',
        	        'onUploadSuccess' : function(file, data, response) {
        	        	      data = eval("(" + data + ")");      	        
        	                 alert( file.name + ' 上传成功！ ');
                           $("#upic").val(data.picurl);
        	            $("#uuploadButton").hide();
        	            
        	        },
         'onFallback' : function() {
           alert('Flash was not detected.');
        },
         "onSelect" : function(file) {
            $("#uuploadButton").show();
        },
           "onCancel" : function() {
            $("#uuploadButton").hide();
            $("#uonlyOneImg").show();
        },
 		        });
	     
	     
	  });
    /**修改友情链接信息**/
     function updateManager(){
         var uid=$.trim($("#uid").val()); 
         var uname=$.trim($("#uname").val());  
	     var uurl=$.trim($("#uurl").val());
	     var upic=$.trim($("#upic").val()); 
	    if(upic.length==0  || uname.length==0||uid.length==0||upic.length==0){
	      alert("输入信息不能为空!");
	        return false;
	    } 
	     $.ajax( {
				type : "POST",
				url : "<%=request.getContextPath()%>/back/news/updatelink.do",
				data:{"id":uid,"name":uname,"url":uurl,"pic":upic},
				dataType: "json",
				async : false,
				success : function(data) {
					if(data.code=="0000"){
			       		 alert("操作成功!");
			       		 location.reload();
			       }else{
			           alert(data.code+data.codeMsg);
			       }
				}
		  });         
     }
      /**添加友情链接信息**/
     function addManager(){
	    var iname=$.trim($("#iname").val());  
	    var iurl=$.trim($("#iurl").val());
	    var ipic=$.trim($("#ipic").val());
	    if(iname.length==0  || iurl.length==0 || ipic.length==0){
	      alert("输入信息不能为空!");
	        return false;
	    } 
	     $.ajax( {
				type : "POST",
				url : "<%=request.getContextPath()%>/back/news/addLink.do",
				data:{"name":iname,"pic":ipic,"url":iurl},
				dataType: "json",
				async : false,
				success : function(data) {
					if(data.code=="0000"){
			       		 alert("操作成功!");
			       		 location.reload();
			       }else{
			           alert(data.code+data.codeMsg);
			       }
				}
		  });            
     }
        /**删除本条数据*/
         function del(id){
          $.ajax( {
				type : "POST",
				url : "<%=request.getContextPath()%>/back/news/delLink.do",
				data:{"id":id},
				dataType: "json",
				async : false,
				success : function(data) {
					if(data.code=="0000"){
			       		 alert("操作成功!");
			       		 location.reload();
			       }else{
			           alert(data.code+data.codeMsg);
			       }
				}
		  });      
        }
   </script>
<title>Document</title>


</head>
<body  >
	<div class="container">
		<div class="main_top">

			<div class="main_right fr span10">

				<div class="box pl5">
					<div class="box_border">
						<div class="box_top">
							<div class="box_top_l fl">
								<b class="pl15">数据</b>
							</div>
						</div>
						<div class="box_center">
								<div class="searchDiv fr">
								<input type="button"  id="add_manager"  class="new_btn new_btn_publish new_btn_big" 
											value="添加数据">
								</div>
							<div id="table" class=" fl mt10">
								<div class="box span10 oh">
									<table width="100%" border="0" cellpadding="0" cellspacing="0"
										class="list_table">
										<tr>
											<th width="1.5%">序号</th>
											<th width="3%">名称</th>
											<th width="3%">图片</th>
											<th width="5%">链接</th>
											<th width="3%">操作</th>
										</tr>
										<c:if test="${fn:length(linkBeans)==0}"><tr class="tr"><td align="center" colspan="5">暂无数据</td> </tr></c:if>
										<c:if test="${fn:length(linkBeans)>0}">
										<c:forEach items="${linkBeans}" var="dic" varStatus="abc">
											<tr class="tr">
											    <td align="center"><c:out value="${(PageBean.currentpage-1)*PageBean.pagesize+abc.index + 1}" /></td>
											    <td align="center"><c:out value="${dic.name}" /></td>
                                                  <td align="center">
                                                     <a href="<%=imgPath %>${dic.pic}" data-lightbox="image-1" id="showImg" > 
                                                     <IMG alt="活动缩略图" width="50" height="50" src="<%=imgPath %>${dic.pic}"/>
                                                     </a>
                                                 </td>
                                                  <td align="center">
                                                    <c:out value="${dic.url}" />
                                                 </td>
												<td align="center">
												  <input type="button" class="new_btn new_btn_up" value="更新"  >
												   <input type="button" class="new_btn new_btn_delete" value="删除"  onclick="javascript:del('${dic.id}');" >
												  </td>
												 <td style="display:none;"><c:out value="${dic.id}" /></td>
												  <td style="display:none;"><c:out value="${dic.pic}" /></td>
											</tr>
										</c:forEach>
                                     </c:if>
									</table>
									<div class="fr fontblack mt25 mb20 mr20">
										每页条数：<a href="<%=request.getContextPath()%>/back/news/getLinkList.do?pz=5"
											class="${pageSize == 5 ? 'fontpink' : ''}">5</a> | <a
											href="<%=request.getContextPath()%>/back/news/getLinkList.do?pz=10"
											class="${pageSize == 10 ? 'fontpink' : ''}">10</a> | <a
											href="<%=request.getContextPath()%>/back/news/getLinkList.do?pz=20"
											class="${pageSize == 20 ? 'fontpink' : ''}">20</a>
									</div>
									<div class="fr fontblack mt5 mb20 mr20">
										<jsp:include page="../template/commonPagination.jsp">
											<jsp:param name="url" value="getLinkList.do?"></jsp:param>
										</jsp:include>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="clear"></div>
		</div>

	</div>
	
 <script type="text/javascript">
	     $("#table tr").on("click", "td:eq(4) input:eq(0)", function(e) {
	        closeOtherJDialog();
	        e.stopPropagation();
	        var dialog =  $("#update_manager_dialog");
	         dialog.dialog("open");
              var tr = $(this).parent().parent();
		      tr.data("tdArr", ["td:eq(5)","td:eq(1)","td:eq(3)","td:eq(6)"]);
		      tr.data("inputArr", ["input:eq(0)","input:eq(1)","input:eq(2)","input:eq(3)"]);
		      for (var i = 0, length = tr.data("tdArr").length; i < length; i++) {
		       $(tr.data("inputArr")[i], dialog).val($.trim($(tr.data("tdArr")[i], tr).text()));
		 }
   
	     });
  </script> 
		<!-- 添加友情链接信息 -->
		<div id="add_manager_dialog" title="添加友情链接信息 " style="display:none;">
		<div class="box span10 oh">
			<table class="list_table"  id="tb_version_update" >
			   <tr class="tr">
					<td align="left">&nbsp;&nbsp;名称:</td>
					<td>
					  <input type="text" id="iname" name="iname" class="input-text_popup_form" style="width:300px" maxlength="50">
				   </td>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;图片:</td>
					<td>
					<div>
					<input type="hidden" id="ipic"   />
							<input type="file" name="fileName" class="ml10" style="height:36px;" id="file_upload" /> 
							<input id="uploadButton" type="button"
								onclick="$('#file_upload').uploadify('upload');" value="开始上传"
								class="ext_btn ext_btn_success" style="display:none;">
							<p class="fontpink" id="onlyOneImg" style="display:none;">只能上传一张图片</p>
							</div>
                    </td>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;链接:</td>
					<td>
					  <input type="text" id="iurl" name="iurl" class="input-text_popup_form" style="width:300px" maxlength="50">
					</td>
				</tr>
			</table>
		</div>
		</div>
		<!-- 修改互动主题信息 -->
		<div id="update_manager_dialog" title="修改互动主题信息 " style="display:none;">
		<div class="box span10 oh">
		<input type="hidden" id="uid"   />
			<table class="list_table"  id="tb_version_update" >
			  <tr class="tr">
					<td align="left">&nbsp;&nbsp;名称:</td>
					<td> 
					  <input type="text" id="uname" name="uname" class="input-text_popup_form" style="width:300px" maxlength="50">
				    </td>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;链接:</td>
					<td>
					   <input type="text" id="uurl" name="uurl" class="input-text_popup_form" style="width:300px" maxlength="50">
						
					</td>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;活动图片:</td>
					<td>
					<div>
					<input type="hidden" id="upic"   />
							<input type="file" name="fileName" class="ml10" style="height:36px;" id="ufile_upload" /> 
							<input id="uuploadButton" type="button"
								onclick="$('#ufile_upload').uploadify('upload');" value="开始上传"
								class="ext_btn ext_btn_success" style="display:none;">
							<p class="fontpink" id="uonlyOneImg" style="display:none;">只能上传一张图片</p>
							</div>
                    </td>
				</tr>
				
			</table>
		</div>
		</div>
		
</body>

</html>
